<template>
  <div>
    <div class="my_dog">
      <img :src="dogImgUrl" alt="" />
      <p @click="changecolor" :style="{ background: color }">{{ dogName }}</p>
    </div>
  </div>
</template>

<script>
export default {
  name: "MyDog4",
  components: {},
  props: {
    dogImgUrl: String,
    dogName: String,
  },
  data() {
    return {
      color: "",
    };
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    changecolor() {
      this.color = `rgb(${Math.floor(Math.random() * 256)},${Math.floor(
        Math.random() * 256
      )},${Math.floor(Math.random() * 256)})`;
      this.$emit("love", this.dogName);
    },
  },
};
</script>

<style scoped>
.my_dog {
  width: 200px;
  border: 1px solid black;
  text-align: center;
  float: left;
  margin-right: 10px;
}

.my_dog img {
  width: 100%;
  height: 200px;
}
</style>
